

function timesLimit(a,b,limit) {   
    var tmp = a*b;
    return tmp%limit;
}

function pe48() {
    var limit=10000000000;
    var tmp = 0, tmp2;
    for(var i=1; i<=1000; i++) {
        var tmp2 = 1;
        for(var j=1; j<=i; j++) {
            tmp2 = timesLimit(tmp2, i, limit);
        }
        tmp = (tmp + tmp2) % limit;
    }
    return tmp;
}

print(pe48());

